const SOFTWARE_PLATFORM = {
    APP: 'App端',
    WEB: 'Web端',
    PC: 'PC端'
};

export const filterSoftwarePlatform = (platform = {}) => {
    const platformList = Object.keys(SOFTWARE_PLATFORM);

    const result = [];
    platformList.forEach(item => {
        if (platform[item]) {
            result.push(SOFTWARE_PLATFORM[item]);
        }
    });
    return result.join('、');
};

export const findHighestFunctionGrade = (newFunctionList = []) => {
    let result = -1;

    function resolveFunctionGrade(treeData) {
        treeData.forEach(item => {
            const { functionGrade, children } = item;
            if (functionGrade > result) {
                result = functionGrade;
            }
            if (Array.isArray(children) && children.length) {
                resolveFunctionGrade(children);
            }
        });
    }

    resolveFunctionGrade(newFunctionList);

    return result;
};
